package com.chj.design.sk;

public class Code18_Facade2 {
	// 灯类
	public static class SubSystemA_Light {
		public void on() {
			System.out.println("打开了灯....");
		}

		public void off() {
			System.out.println("关闭了灯....");
		}
	}

	// 电视类
	public static class SubSystemB_Television {
		public void on() {
			System.out.println("打开了电视....");
		}

		public void off() {
			System.out.println("关闭了电视....");
		}
	}

	// 空调类
	public static class SubSystemC_Aircondition {
		public void on() {
			System.out.println("打开了空调....");
		}

		public void off() {
			System.out.println("关闭了空调....");
		}
	}

	public static class Facade {

		SubSystemA_Light light;
		SubSystemB_Television television;
		SubSystemC_Aircondition aircondition;

		// 传参
		public Facade(SubSystemA_Light light, SubSystemB_Television television, SubSystemC_Aircondition aircondition) {
			this.light = light;
			this.television = television;
			this.aircondition = aircondition;

		}

		// 起床后一键开电器
		public void on() {
			System.out.println("起床了");
			light.on();
			television.on();
			aircondition.on();

		}

		public void off() {
			// 睡觉时一键关电器
			System.out.println("睡觉了");
			light.off();
			television.off();
			aircondition.off();
		}
	}

	public static void main(String[] args) {
		// 实例化电器类
		SubSystemA_Light light = new SubSystemA_Light();
		SubSystemB_Television television = new SubSystemB_Television();
		SubSystemC_Aircondition aircondition = new SubSystemC_Aircondition();

		// 传参
		Facade facade = new Facade(light, television, aircondition);

		// 客户端直接与外观对象进行交互
		facade.on();
		System.out.println("可以看电视了");
		facade.off();
		System.out.println("可以睡觉了");
	}
}
